package com.itbaizhan.listener;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
测式HttpServletRequest属性监听器
HttpServletRequestAttrListener.java相关联*/
//注解
@WebServlet("/requestAttr.do")
public class HttpServletRequestAttrServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取HttpServletRequest对象，而这里可以直接获取，
        // 因为doGet()方法传进来的参数就是它
        req.setAttribute("key","request");
        //替换value，相同的key,
        req.setAttribute("key","replace");
        req.removeAttribute("key");
    }
}
